I am looking at Instacart data.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.4 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 2.0.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(p8105.datasets)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
data("instacart")
instacart_subset =
instacart %>%
mutate(mean_hour = mean(order_hour_of_day)) %>%
select(product_name, order_dow, order_hour_of_day, aisle, department, mean_hour) %>%
mutate(
order_dow =
recode_factor(order_dow, "0" = "Monday", "1" = "Tuesday", "2" = "Wednesday", "3" = "Thursday", "4" = "Friday", "5" = "Saturday", "6" = "Sunday"))
instacart_subset %>%
filter(
department == "produce"
) %>%
count(product_name) %>%
plot_ly(
x = ~product_name, y = ~n, type = "scatter", mode = "markers")
This shows the number of each item in the produce department.
instacart_subset %>%
plot_ly(y = ~department, color = ~order_dow, type = "box", colors = "viridis")